package controllers.service;

import java.util.List;

import javax.persistence.EntityManager;

import play.db.jpa.Transactional;
import enumerators.Tables;
import models.domain.Customer;
import models.domain.User;
import models.persistence.JPAUtil;
import models.persistence.StaticQuerries;

public class LoginService {

	/**
	 * Returning true on correct user input credentials
	 * 
	 * @param user
	 * @return
	 */	
	public boolean validateLogin(String username,String password) {
		EntityManager em = JPAUtil.getCurrentEntityManager();
		List<Customer> lstCustomers = em.createQuery(
				"select customers from " + Tables.Customer
						+ " customers where userName='" + username
						+ "' and Password='" + password + "'")
				.getResultList();
		if (lstCustomers.isEmpty()) {
			return false;
		} else {
			return true;
		}

	}

}
